name: E2E Techdocs
on:
  pull_request:
    paths:
      - 'yarn.lock'
      - '.github/workflows/verify_e2e-techdocs.yml'
      - 'packages/techdocs-cli/**'
      - 'packages/techdocs-cli-embedded-app/**'
      - 'plugins/techdocs/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  verify:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [18.x, 20.x]

    env:
      CI: true
      NODE_OPTIONS: --max-old-space-size=4096

    name: Techdocs
    steps:
      - name: Harden Runner
        uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
        with:
          egress-policy: audit

      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
      - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
        with:
          python-version: '3.9'

      - name: install dependencies
        run: yarn install --immutable

      - name: generate types
        run: yarn tsc

      - name: build techdocs-cli
        working-directory: packages/techdocs-cli
        run: yarn build

      - name: Install mkdocs & techdocs-core
        run: python -m pip install mkdocs-techdocs-core==1.1.7 mkdocs==1.4.0

      - name: techdocs-cli e2e test
        working-directory: packages/techdocs-cli
        run: yarn test:e2e:ci
        env:
          BACKSTAGE_TEST_DISABLE_DOCKER: 1
